home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8411.arc / TEST.BAS < prev   
BASIC Source File  |  1986-09-14  |  2KB  |  95 lines

  1. 'Program Name: TEST.BAS
  2. 'Author: William L. Colsher
  3. 'Date Written: May 21, 1984
  4. 'Purpose: This program exercises the 3Com/EtherNet Semaphore
  5. '      protocol implemented in the Assembly language program
  6. '      ELOCK.ASM
  7. '
  8. 'Variables: DR% - EtherShare disk drive number
  9. '        SEM$ - Semaphore name
  10. '        RC% - Return code from EtherShare
  11. '        TI% - Time Out value for WAITLOCK
  12. '
  13.  
  14. DR%=5 
  15.  
  16. 'First Test - Attempt to lock a simple semaphore
  17.  
  18. SEM$="TESTSEMAPHORE0001"+CHR$(0)
  19. CALL LOCK(DR%,SEM$,RC%)
  20. PRINT "Return code from simple LOCK is: ";RC%
  21. GOSUB 5000
  22.  
  23. 'Second Test - Unlock the Semaphore just locked
  24.  
  25. CALL UNLOCK(DR%,SEM$,RC%)
  26. PRINT "Return code from UNLOCK is: ";RC%
  27. GOSUB 5000
  28.  
  29. 'Third Test - Try to force some errors.  First standalone error
  30. '             is #3 - Invalid semaphore name.
  31.  
  32. SEM$="THIS IS AN INVALID SEMAPHORE NAME"+CHR$(0)
  33. CALL LOCK(DR%,SEM$,RC%)
  34. PRINT "Return code from attempted invalid semaphore name is:";RC%
  35. GOSUB 5000
  36.  
  37. 'Fourth Test - Try for a semaphore list full error: #4.  We have to
  38. '           LOCK 51 semaphores to do it.
  39.  
  40. FOR I=1 TO 50
  41.     SEM$="SEMAPHORE"+STR$(I)+CHR$(0)
  42.     CALL LOCK(DR%,SEM$,RC%)
  43.     NEXT I
  44.  
  45. SEM$="THE LAST SEMAPHORE"+CHR$(0)
  46. CALL LOCK(DR%,SEM$,RC%)
  47. PRINT "Return code from 51st LOCK is:";RC%
  48. GOSUB 5000
  49.  
  50. 'Clean up the mess
  51.  
  52. FOR I=1 TO 50
  53.     SEM$="SEMAPHORE"+STR$(I)+CHR$(0)
  54.     CALL UNLOCK(DR%,SEM$,RC%)
  55.     NEXT I
  56.  
  57. 'Fifth Test - Invalid drive ID is return code 5.  
  58.  
  59. SEM$="TEST SEMAPHORE"+CHR$(0)
  60. DR%=1
  61.  
  62. CALL LOCK(DR%,SEM$,RC%)
  63. PRINT "Return code from LOCK with Drive ID=0 is: ";RC%
  64. GOSUB 5000
  65.  
  66. 'Sixth Test - The last stand alone error is #9, Semaphore
  67. '          Already Locked by this PC.
  68.  
  69. DR%=5
  70.  
  71. CALL LOCK(DR%,SEM$,RC%)
  72. CALL LOCK(DR%,SEM$,RC%)
  73. PRINT "Return code from duplicate LOCK is: ";RC%
  74. GOSUB 5000
  75.  
  76. CALL UNLOCK(DR%,SEM$,RC%)
  77.  
  78. STOP
  79.  
  80. 5000 'This routine displays error messages
  81. 5010 ON RC%+1 GOSUB 5100,5200,5300,5400,5500,5600,5700,5800,5900,6000
  82. 5020 RETURN
  83. 5100 PRINT"Operation successful":RETURN
  84. 5200 PRINT"Semaphore currently locked":RETURN
  85. 5300 PRINT"Server not responding":RETURN
  86. 5400 PRINT"Invalid semaphore name":RETURN
  87. 5500 PRINT"Semaphore list full":RETURN
  88. 5600 PRINT"Invalid drive id":RETURN
  89. 5700 PRINT"Invalid Ethernet address":RETURN
  90. 5800 PRINT"Not logged in":RETURN
  91. 5900 PRINT"Write to network failed":RETURN
  92. 6000 PRINT"Semaphore already locked by this PC":RETURN
  93.  
  94. END
  95.